package net.mikoo.seals.biz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import net.mikoo.seals.biz.mapper.NoticeMapper;
import net.mikoo.seals.biz.service.NoticeServices;
import net.mikoo.seals.common.model.PageModel;
import net.mikoo.seals.model.Notice;
import net.mikoo.seals.model.NoticeQuery;

public class NoticeServicesImpl implements NoticeServices {

	@Autowired
	private NoticeMapper noticeMapper;

	@Override
	public PageModel<Notice> getPageByQuery(NoticeQuery query) {
		
		if(query == null) {
			throw new IllegalArgumentException("query");
		}
		if(query.getCompanyId() == null) {
			throw new IllegalArgumentException("CompanyId is null");
		}
		if(query.getPartyId() == null) {
			throw new IllegalArgumentException("PartyId is null");
		}
		
		List<Notice> datas = noticeMapper.selectPageByQuery(query);
		Integer total = noticeMapper.countPageByQuery(query);
		
		PageModel<Notice> pm = new PageModel<Notice>(total,datas);
		
		return pm;
	}
	
}
